package com.yihang.jdbcDemo;

import com.yihang.jdbcDemo.ftp.CertificationFptFile;
import com.yihang.jdbcDemo.ftp.config.FtpClientProperties;
import com.yihang.jdbcDemo.ftp.core.FtpClientFactory;
import com.yihang.jdbcDemo.ftp.core.FtpClientTemplate;
import com.yihang.jdbcDemo.utils.SpringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Bean;

import java.util.Base64;

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class DataJdbcDemoApplication implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(DataJdbcDemoApplication.class, args);
    }

    private FtpClientProperties ftpClientProperties;

    @Autowired
    public void setFtpClientProperties(FtpClientProperties ftpClientProperties) {
        this.ftpClientProperties = ftpClientProperties;
    }

    @Bean
    public FtpClientFactory getFtpClientFactory() {
        return new FtpClientFactory(ftpClientProperties);
    }

    @Bean
    public FtpClientTemplate getFtpTemplate() {
        return new FtpClientTemplate(getFtpClientFactory());
    }

    @Bean
    public SpringUtil getSpringUtil2() {
        return new SpringUtil();
    }

    @Override
    public void run(String... args) throws Exception {
        Thread thread = new Thread(new CertificationFptFile());
        thread.start();
    }
}
